Release 10.1A: OpenEdge Development:
Web Services


Coding options for wrapped document literal

For Wrapped Doc/Lit operations, the 4GL allows you to use one or both of two alternate forms for accessing the operation INPUT and OUTPUT parameters using 4GL procedures and functions. You can either access them in wrapped form as XML strings containing the complex data for each SOAP message (request and response) or you can access them in unwrapped form as several 4GL parameters, in many cases, with simple 4GL data types. You can overload these forms. That is, you can use both forms for the same operation in the same client session.

Using the wrapped form

Suppose you have a Wrapped Doc/Lit operation, foo. The one complex input parameter contains a single element with two child elements, XML Schema boolean and int values. The one complex output parameter also contains a single element with two child elements, XML Schema int and string values. Using the wrapped form, you might run the foo procedure with the INPUT parameter (param1) set to the XML string as shown in this example:

Wrapped Doc/Lit operation — wrapped form
DEFINE VARIABLE param1 AS LONGCHAR NO-UNDO. 
DEFINE VARIABLE param2 AS LONGCHAR NO-UNDO. 
param1 = ” 
<ns0:foo xmlns:ns0=’http://tempuri.org/’>  
  <ns0:bBoolean>true</ns0:bBoolean>  
  <ns0:iInteger>17</ns0:iInteger> 
</ns0:foo>” 
RUN foo IN hWebService (INPUT param1, OUTPUT param2). 
DISPLAY “Returned from web service call:” SKIP 
  “  param2 = ” SKIP param2 NO-LABEL FORMAT “x(200)”. 

On the return, you might display an XML string in the OUTPUT parameter (param2) as follows:

Returned from web service call: 
  param2 =  
<ns0:fooResponse xmlns:ns0=’http://tempuri.org/’> 
  <ns0:iInteger>18</ns0:iInteger> 
  <ns0:cString>Hello world!</ns0:cString> 
</ns0:fooResponse>  

Clearly, to work with the individual values contained in these parameters, you must treat them as complex data (see the "Complex data example" section).

Using the unwrapped form

Using the unwrapped form for the same Wrapped Doc/Lit operation, foo, you can access all the parameter values individually using 4GL data types. In this case, the WSDL Analyzer recognizes that there is a single INTEGER mapping for a value in both complex input and output parameters of the wrapped operation. So, it prescribes a single INPUT-OUTPUT parameter for that INTEGER mapping (iInteger). It prescribes individual INPUT and OUTPUT modes for the remaining values, as indicated in this example:

Wrapped Doc/Lit operation — unwrapped form
DEFINE VARIABLE bBoolean AS LOGICAL NO-UNDO. 
DEFINE VARIABLE iInteger AS INTEGER NO-UNDO. 
DEFINE VARIABLE cString AS CHARACTER NO-UNDO. 
bBoolean = true. 
iInteger = 17. 
RUN foo IN hWebService (INPUT bBoolean, INPUT-OUTPUT iInteger,  
                        OUTPUT cString).  
DISPLAY “Returned from web service call:” SKIP 
  “  iInteger = ” iInteger NO-LABEL SKIP 
  “  cString  = ” cString NO-LABEL FORMAT “x(12)”. 

On return, you might display the individual OUTPUT values (iInteger and cString) as follows:

Returned from web service call: 
  iInteger = 18 
  cString  = Hello world! 

No further work is required to access these values in the 4GL.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095